package com.dingup.provider.feign.server.sys;

import com.dingup.api.model.sys.SysUser;
import com.dingup.provider.mapper.SysDeptMapper;
import com.dingup.provider.mapper.SysUserMapper;
import com.dingup.provider.service.sys.LoadUserPermissionService;
import com.dingup.provider.service.sys.SysDeptService;
import com.dingup.provider.service.sys.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wancheng on 2018/7/28.
 */
@RestController()
@RequestMapping("/sysUser")
public class SysUserFeign {

    @Autowired
    SysUserMapper sysUserMapper;
    @Autowired
    SysUserService sysUserService;

    @Autowired
    SysDeptService sysDeptService;

    @Autowired
    SysDeptMapper sysDeptMapper;
    @Autowired
    LoadUserPermissionService loadUserPermissionService;

    @RequestMapping(value = "/userAccount/{userAccount}")
    public SysUser getByUserAccount(
            @PathVariable("userAccount") String userAccount) {
        SysUser user = sysUserMapper.getByUserAccount(userAccount);
        return user;
    }

    @RequestMapping(value = "/userId/{userId}")
    public SysUser getByUserUserId(@PathVariable("userId") String userId) {
        SysUser user = sysUserMapper.selectByPrimaryKey(userId);
        return user;
    }

    @RequestMapping(value = "/union_id/{unionId}")
    public SysUser getByUnionId(@PathVariable("unionId") String unionId) {
        SysUser user = sysUserMapper.getByUnionId(unionId);
        return user;
    }


    @RequestMapping(value = "/load_user_data_permission/{userAccount}")
    public void loadUserDataPermission(@PathVariable("userAccount") String userAccount) {
        loadUserPermissionService.loadUserDataPermission(userAccount);
    }

    ;
}
